[BUG] APIRequest doesn't support --max-http-header-size or something, leads to Header overflow #28873
Description
System info
- Playwright Version: 1.40.1
- Operating System: All
- Browser: Chromium (didn't test in others)
Source code
APIRequest.newContext().post(url, {
data: requestBody,
headers: {
// Headers like Cookie:
// To reproduce it should be enough to provide any large string of cookies
}
});
Here you usually include some headers - cookies, etc which you can get by using page.context() or set by yourself. If using headers longer than 8KB (or 16KB in latest node versions) you get Parse Error: Header Overflow preventing you from sending a request.
Expected
Setting node --max-http-header-size=SOME_BIG_NUMBER allows sending large headers for libraries like node-fetch etc.
Note that I'm actually using
node --max-http-header-size=5242880 -r ts-node/register ./src/main/main.ts
which still works fine with node-fetch, but not with APIRequest.
Actual
Playwright seems not to be affected by that option, and there's no other setting to allow sending large headers.
Also note that executing default fetch in browser via Page.evaluate of course works fine and this seems to be an issue related only to APIRequest.
Activity
roosalbe commentedon Jan 5, 2024
I have got a similar issue with --insecure-http-parser that cannot be passed to Playwright
mxschmitt commentedon Jan 8, 2024
Works for me, I was not able to reproduce:
@roosalbe please file a separate issue. But it should work as well.
nonme commentedon Jan 11, 2024
@mxschmitt I will look into it on weekends, thanks for your code snippet and a quick reply. Might be some compatibility issue between ts-node and Playwright as well, but the strange thing is that it's works for node-fetch but doesn't for Playwright. But I will look into it and report if this is not on Playwright's end.
mxschmitt commentedon Jan 16, 2024
Closing in the meantime as part of our triage process. Feel free to re-file and reference this issue if you still encounter any issues.